package com.command.demo3;

public class CeilingFan {
	// 状态位
	public static final int HIGH = 3;
	public static final int MEDIUM = 2;
	public static final int LOW = 1;
	public static final int OFF = 0;
	String location;
	// 当前状态
	int speed;

	public CeilingFan(String location) {
		this.location = location;
		speed = OFF;
	}

	public void high() {
		// 记录当前状态
		speed = HIGH;
		System.out.println(location + "电风扇处于高速");
	}

	public void medium() {
		speed = MEDIUM;
		System.out.println(location + "电风扇处于中速");
	}

	public void low() {
		speed = LOW;
		System.out.println(location + "电风扇处于低速");
	}

	public void off() {
		speed = OFF;
		System.out.println(location + "电风扇关闭");
	}

	public int getSpeed() {
		return speed;
	}
}
